home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pn.arc / PNT1.PAS < prev   
Pascal/Delphi Source File  |  1985-08-12  |  3KB  |  97 lines

  1. program PNT1(data, out, output, kbd);
  2.  
  3.    { PNT1.PAS #2.00 85-08-06 NORMAL PROBABILITY DISTRIBUTION TEST DRIVER
  4.  
  5.               V02 L00 derived 85-08-06 by Dennis E. Hamilton for testing
  6.                       of Turbo Pascal version, PN.PLB.  This is a direct
  7.                       clone of ERFT1.PAS.
  8.               V01 L02 completed on 79-03-22 by DEH for verifying erf(x)
  9.                       and PN(x) using Benton Harbor Basic #5.01.01.      }
  10.  
  11.  
  12. var
  13.  
  14.    data: text {source of test input values};
  15.  
  16.     out: text {presentation of the test results};
  17.  
  18.       x: real {test value from data };
  19.      px: real {known value for PN(x) to be checked};
  20.  
  21.  
  22. {$I  PN.PLB } {Vintage 2.00 definition for PN(x) }
  23.  
  24. procedure
  25.  
  26.    commentary;
  27.  
  28.    var    c: char;
  29.        line: string[255];
  30.  
  31.    begin {transfer comment lines (" in column 1) from the input data to the
  32.           output report until non-comment lines are produced.}
  33.  
  34.    read(data, c);
  35.  
  36.    while (c = '"') or (c = '/')
  37.       do begin
  38.          if c = '/'
  39.          then begin
  40.               writeln;
  41.               write('PNT1> Press any key to continue: ');
  42.               read(KBD, c);
  43.               ClrScr;
  44.               writeln('PNT1> #2.00 85-08-06 NORMAL PROBABILITY DISTRIBUTION',
  45.                               ' FUNCTION');
  46.               writeln;
  47.               end;
  48.          c := ' ';
  49.             {replacing the " by blank to indicate already noticed}
  50.          readln(data, line);
  51.          writeln(out, line);
  52.          if not eof(data)
  53.          then read(data, c);
  54.          end;
  55.    end {commentary};
  56.  
  57. BEGIN {PNT1.PAS}
  58. CrtInit;
  59.  
  60. assign(out, 'CON:');  {or a filename for capturing the test report}
  61. rewrite(out);
  62.  
  63. writeln(out, 'PNT1> #2.00 85-08-06 NORMAL PROBABILITY DISTRIBUTION',
  64.                      ' FUNCTION');
  65. writeln(out);
  66.  
  67. assign(data, 'PNT1.DAT');
  68. reset(data);  {preparing to access the test data file.}
  69.  
  70. while not EOF(data)
  71.    do begin
  72.       commentary;
  73.       if not EOF(data)
  74.       then begin
  75.            readln(data, x, px); {test value and the expected value}
  76.            write(out, '       ');
  77.            if (abs(x) < 1.0E-8) or (abs(x) >= 10.0)
  78.            then if x < 0
  79.                 then write(out, x :16)
  80.                 else write(out, ' ', x :15)
  81.            else write(out, x :12:9, '    ');
  82.            write(out, '   ');
  83.            if abs(PN(x)) < 1.0E-8
  84.            then write(out, PN(x) :16)
  85.            else write(out, PN(x) :13:11, '   ');
  86.            writeln(out, '      ', abs(PN(x)-px) :8);
  87.            end;
  88.       end;
  89.  
  90. writeln(out);
  91.  
  92. close(data);
  93. close(out);
  94.  
  95. CrtExit;
  96. END. {PNT1}
  97.